﻿<%@ Control Language="C#" Inherits="Forum.Business.ThreadEdit, Forum.Business" AutoEventWireup="true" %>
<%@Register tagPrefix="ctrl" tagName="Editor" src="~/themes/default/skins/Skin-HtmlEditor.ascx" %>

<script type="text/javascript">
    function checkForm(){
         var subjectTextBox = document.getElementById('<%= subjectTextBox.ClientID %>');
         var title = subjectTextBox.value;
         title = title.toText().Trim();
         if(title == null || title == "")
         {
               alert('标题不能为空!');
               subjectTextBox.focus();
               return false;
         }
         
         var threadMarksTextBox = document.getElementById('<%= threadMarksTextBox.ClientID %>');
         var threadMarks = threadMarksTextBox.value;
         threadMarks = threadMarks.toText().Trim();
         if(threadMarks == null || threadMarks == "")
         {
               alert('帖子分数不能为空!');
               threadMarksTextBox.focus();
               return false;
         }
         if(isNaN(threadMarks)){ 
               alert('帖子分数必须输入数字!');
               threadMarksTextBox.focus();
               return false;
         } 
         if (!checkPositiveNumber(threadMarks))
         {
               alert('帖子分数必须是正整数!');
               threadMarksTextBox.focus();
               return false;
         }
         if (threadMarks > 500)
         {
               alert('帖子分数必须小于等于500!');
               threadMarksTextBox.focus();
               return false;
         }
         
         var bodyEditor = tinyMCE.getInstanceById("<%= bodyEditor.EditorClientID %>");
         var content = bodyEditor.getBody().innerHTML;
         content = content.toText().Trim();
         if(content==null||content=="")
         {
               alert('内容不能为空!');
               tinyMCE.execCommand('mceFocus', false, '<%= bodyEditor.EditorClientID %>');
               return false;
         }
        return true;
    } 
</script>

<div class="AdminArea">
    <fieldset>
        <legend><ctrl:ResourceLiteral runat="server" ResourceName="System_ControlPanel_Thread_EditControlTitle" ResourceFile="ControlPanelResources.xml" /></legend>
        <div class="FormRow">
            <ctrl:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="subjectTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_ControlPanel_Thread_Subject" />
            <ctrl:ValuedTextBox Runat="server" CssClass="InputField MiddleWidth" id="subjectTextBox" />
        </div>
        <div class="FormRow">
            <ctrl:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="threadMarksTextBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_ControlPanel_Thread_Marks" />
            <ctrl:ValuedTextBox Runat="server" CssClass="InputField MicroWidth" id="threadMarksTextBox" MaxLength="3" />
        </div>
        <div class="FormRow">
            <ctrl:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="isRecommendedCheckBox" ResourceFile="ControlPanelResources.xml" ResourceName="System_ControlPanel_Thread_IsRecommended" />
            <ctrl:ValuedDropDownList CssClass="DropDownList" Runat="server" id="threadStatusDropDownList" />
        </div>
        <div class="FormRow">
            <ctrl:ResourceLabel CssClass="FieldName" runat="Server" ControlToLabel="bodyEditor" ResourceFile="ControlPanelResources.xml" ResourceName="System_ControlPanel_Thread_Body" />
            <br /><br /><ctrl:Editor Runat="server" Width="100%" Height="250px" id="bodyEditor" />
        </div>
        <div class="FormRow SubmitButtonRow">
            <ctrl:Resourcebutton id="saveButton" ResourceName="Save" CssClass="Button" Runat="server"></ctrl:Resourcebutton>
        </div>
    </fieldset>
</div>